<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery1">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="发票号码">
              <a-input placeholder="请输入发票号码" v-model="queryParam.fphm"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="发票抬头">
              <a-input placeholder="请输入发票抬头" v-model="queryParam.gfmc"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目编号">
              <!--没有项目编号字段,用ids来代替传值-->
              <a-input placeholder="请输入项目编号" v-model="queryParam.ids"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="发票样式">
              <j-dict-select-tag placeholder="请选择发票样式" v-model="queryParam.fpys" dictCode="fpys"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
      <i class="anticon anticon-info-circle ant-alert-icon"></i> 开票总金额: <a style="font-weight: 600">{{ fp.sumKpzje }}</a>
    </div>
    <div>
      <!--<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>-->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>
        </span>

      </a-table>
    </div>

    <lhyg-invoice-modal ref="modalForm" @ok="modalFormOk"/>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import LhygInvoiceModal from './modules/LhygInvoiceModal'
  import '@/assets/less/TableExpand.less'
  import JInput from '@/components/jeecg/JInput'
  import {getAction} from "@api/manage";

  export default {
    name: "LhygInvoiceList",
    mixins:[JeecgListMixin],
    components: {
      LhygInvoiceModal,
      JInput,
    },
    data () {
      return {
        fp: {
          sumKpzje: 0,
        },
        description: '发票表管理页面',
        // 表头
        columns: [
          /*{
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },*/
          {
            title:'发票号码',
            align:"center",
            dataIndex: 'fphm'
          },
          {
            title:'发票抬头',
            align:"center",
            dataIndex: 'gfmc'
          },
          {
            title:'纳税人识别号',
            align:"center",
            dataIndex: 'gfnsrsbh'
          },
          {
            title:'发票类型',
            align:"center",
            dataIndex: 'fpys'
          },
          {
            title:'发票内容',
            align:"center",
            dataIndex: 'fpnr'
          },
          // {
          //   title:'开票方',
          //   align:"center",
          //   dataIndex: 'xfmc'
          // },
          {
            title:'开票总金额',
            align:"center",
            dataIndex: 'kpzje'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/invoice/lhygInvoice/list",
          delete: "/invoice/lhygInvoice/delete",
          deleteBatch: "/invoice/lhygInvoice/deleteBatch",
          exportXlsUrl: "/invoice/lhygInvoice/exportXls",
          importExcelUrl: "invoice/lhygInvoice/importExcel",

        },
        dictOptions:{},
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      },

      loadData(arg) {
        if(!this.url.list){
          // this.$message.error("请设置url.list属性!")
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        var params = this.getQueryParams();//查询条件
        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records;
            this.ipagination.total = res.result.total;
            this.fp.sumKpzje=res.message;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
          this.loading = false;
        })
      },

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>